//
//  NSDictionary+Extend.m
//  XLDoctor
//
//  Created by longma on 2018/12/27.
//  Copyright © 2018年 XLH. All rights reserved.
//

#import "NSAttributedString+MJUI.h"

@implementation NSAttributedString (MJUI)


+ (NSMutableAttributedString *)mj_paragraphStyleWithString:(NSString *)str lineSpacing:(CGFloat)lineSpacing font:(UIFont *)font
{
    NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:str];
    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:lineSpacing]; //行高
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [str length])];
    [attributedString addAttribute:NSFontAttributeName
                               value:font
                               range:NSMakeRange(0, [str length])];
    return attributedString;
}

- (CGSize)mj_boundingRectWithSize:(CGSize )size
{
    CGSize attSize = [self boundingRectWithSize:size options: NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size;
    return CGSizeMake(ceil(attSize.width), ceil(attSize.height));
}

@end
